<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title> 评价记录 </title>
</head>
<body>
<?php
require("view_header.php");
?>

<div class="col-lg-offset-1 col-lg-10 col-sm-12 col-xs-12">
    <div class="panel panel-default" style="margin-left: -1.3rem; margin-right: -1.3rem;">
        <div class="panel-body">
            <div id="summary_eval_detail" class="col-lg-12 col-xs-12 col-sm-12">
                <div class="col-lg-12 col-sm-12 col-xs-12">
                    <label>标题：</label>{{recordDetail.title}}
                </div>
                <pre>{{recordDetail.content}}</pre>
                <a class="col-lg-12 col-sm-12 col-xs-12">
                    <a v-if="recordDetail.allowEdit" class="col-offset-2 col-sm-2">
                        <button v-on:click="postRecord(recordDetail.id)">编辑</button>
                    </a>
                    <a class="col-offset-2 col-sm-2" href="summary_eval_list.php">
                        <button>返回</button>
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    var app = new Vue({
        el: "#summary_eval_detail",
        data:{
            recordDetail: {
                id:"",
                title:"",
                content:"",
                allowEdit:false
            }
        },

        created:function () {
            this.loadRecordInfo();
        },

        methods: {
            loadRecordInfo: function () {
                this.recordDetail.id = getUrlKey('id');
                let reqData = {};
                reqData.id = this.recordDetail.id;
                reqData.op = "fetch";
                let param = "para=" + JSON.stringify(reqData);
                new Promise(function (resolve, reject) {
                    $.ajax({
                        type: 'post',
                        url: '../model/summary_eval_router.php',
                        data: param,
                        dataType: 'json',
                        success: function (retData) {
                            if (retData.status) {
                                resolve(retData.dat);
                            }
                            else {
                                reject(retData.msg);
                            }
                        },
                        error:function (dat) {
                            //alert("dddeeee");
                        },
                    });
                }).then(function (detail) {
                    app.recordDetail.id = detail.id;
                    app.recordDetail.title = detail.title;
                    app.recordDetail.allowEdit = detail.allow_edit;
                    app.recordDetail.content = Base64.decode(detail.content);
                }).catch(function (errMsg) {
                    alert('获取评价信息失败:'+errMsg);
                });
            },

            postRecord:function(codeId) {
                let param = "";
                if ( ! isNull(codeId) ) {
                    param = "?id=" + codeId;
                }
                window.location.href="summary_eval_post.php"+param;
            },
        }
    });
</script>
</body>
</html>
